/* * @Author: yeganaaa@163.com مۇختەرجان مەخمۇت muhtarjan mahmood 
@Date: 2020-06-13 11:47:19 
 * @Last Modified by: yeganaaa@163.com مۇختەرجان مەخمۇت muhtarjan mahmood
 * @Last Modified time: 2020-06-13 11:49:56
*/


import {RpcClient, RpcServer} from "dream_rpc";
import {IMessageBusClientInterface, IMessageBusServerInterface} from "../Shared/Interfaces";
import {MessageBusClient, MessageBusClientDelegateState as MessageBusClientState} from "./MessageBusClient";
export enum WorkMode {
    Master = 1,
    Slave = 2
}
export class ChannelMappingValue {
    constructor(public connectedChannels: string[], public clientId: string, public mode: WorkMode = WorkMode.Slave) {
    }
}
export class MessageBusServer extends RpcServer<IMessageBusServerInterface, IMessageBusClientInterface, MessageBusClientState>{
    /**
     * Key is channel address, value is client id.
     */
    public channelClientMappings = new Map<string, ChannelMappingValue>()

    protected async createClientInstance(): Promise<RpcClient<IMessageBusServerInterface, IMessageBusClientInterface, MessageBusClientState>> {
        return new MessageBusClient()
    }
}
